package com.mz.mattress.admin.interceptor;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Component
public class ExcelListener extends AnalysisEventListener<Object> {

    //存储表格数据
    public static List<Object> excelList = new ArrayList<>();

    @Override
    public void invoke(Object data, AnalysisContext context) {
        excelList.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        log.info("数据读取完成");
    }

    public static List getList() {
        return excelList;
    }

    public static void clearList() {
        excelList.clear();
    }

}
